<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>远程操作电脑小工具</title>
    <!-- 引用vue和elementUI-->
    <!--    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">-->
    <!--    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>-->
    <!--    <script src="https://unpkg.com/element-ui/lib/index.js"></script>-->
    <link rel="stylesheet" href="./js/index.css">
    <script src="./js/vue.js"></script>
    <script src="./js/index.js"></script>
    <script src="./js/axios.min.js"></script>
</head>
<body>
<div id="app">
    <div>
<!--        <el-input type="textarea" style="width: 40%; height:150px; margin: 10px 30px;" :rows=6 v-model="inputStr" placeholder="输入脚本"></el-input>-->
<!--        <el-button type="success" style="width: 40%; height:150px; margin: 10px 30px;" @click="doShell">执行脚本</el-button>-->
<!--        <el-button type="success" style="width: 40%; height:150px; margin: 10px 30px;" @click="doCtrl('shutchrome')">关闭浏览器</el-button>-->
<!--        <el-button type="success" style="width: 40%; height:150px; margin: 10px 30px;" @click="doCtrl('shut')">直接关机</el-button>-->
<!--        <el-button type="success" style="width: 40%; height:150px; margin: 10px 30px;" @click="dialogVisible = true">定时关机</el-button>-->
<!--        <el-button type="success" style="width: 40%; height:150px; margin: 10px 30px;" @click="doCtrl('cshut')">取消定时关机</el-button>-->

        <el-button type="success" style="width: 15%; height:66px; margin: 10px 30px;" @click="doCtrl1('/opt/www/wwwroot/zyzx-web/roncoo-education-web/restart.sh')">学校端重新部署</el-button>
        <el-upload class="upload-demo" action="uploadFile" :on-success="handleSuccessed" :on-error="handleError" :file-list="fileList">
            <el-button size="small" type="primary">点击上传</el-button>
        </el-upload>
        使用方法：
        1. 把index.html的上层文件夹修改名称：教师端:parent,机构端:organ,平台端:zyzx-admin
        2. 在此文件夹上右键，打包为zip
        3. 点击上传此zip文件即可，如果提示成功，刷新项目检查即可
        <el-dialog title="提示" :visible.sync="dialogVisible" width="30%">
            <el-input type="text" v-model="shutMinutes" placeholder="输入定时关机分钟数"></el-input>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="shut">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</div>
<script type="text/javascript">
    const vm = new Vue({
        el: '#app',
        data: {
            batPath: "",
            inputStr: "",
            dialogVisible: false,
            shutMinutes: null,
            fileList:[]
        },
        methods: {
            //获取随机数公用方法
            getRandomNum(a, b) {
                return Math.floor(Math.random() * (b - a + 1)) + a;
            },
            doCtrl(cmdScript) {
                if (!cmdScript) this.$message({type: 'error', message: "请输入脚本"});
                let url = "./batCtrl?cmdScript=" + cmdScript;
                if (this.batPath) url += "&batPath=" + this.batPath;
                axios.get(url).then(res => {
                    this.$message({type: 'success', message: res})
                })
            },
            doCtrl1(cmdScript) {
                if (!cmdScript) this.$message({type: 'error', message: "请输入脚本"});
                let url = "./batCtrl1?cmdScript=" + cmdScript;
                if (this.batPath) url += "&batPath=" + this.batPath;
                axios.get(url).then(res => {
                    this.$message({type: 'success', message: res})
                })
            },
            doShell(){
                if (!this.inputStr) this.$message({type: 'error', message: "请输入脚本"});
                this.doCtrl(this.inputStr);
            },
            shut() {
                if(!this.shutMinutes) this.$message({type: 'error', message: "请输入定时关机分钟数"});
                this.dialogVisible = false;
                this.doCtrl("shutdown -s -t " + this.shutMinutes * 60);
            },
            handleSuccessed(response, file, fileList) {
                let res = response.split("\n");
                // res.forEach(item => {console.log(item)})
                this.$message({type: 'success', message: res[res.length-2]});
            },
            handleError(response, file, fileList) {
                this.$message({type: 'success', message: response});
            }
        },
        mounted() {}
    })
</script>
</body>
</html>